home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / OPUSREG.SLT < prev    next >
Text File  |  1992-03-20  |  9KB  |  280 lines

  1. //-----------------------------------------------------------
  2. // OPUSREG.SL? Automatic registration to a new OPUS BBS system.
  3. //
  4. // Please look at the comments through the whole file, and modify to
  5. // suit your needs before you use it. Then recompile with CS OPUSREG. 
  6. //-----------------------------------------------------------
  7.  
  8. // If you have suggestions for improving this script, please suggest
  9. // improvements to me via old-fashioned snail-mail to:
  10.  
  11. // Author:  Inge Vabekk
  12. //          Hamangskogen 108
  13. //          N-1300 SANDVIKA
  14. //          NORWAY
  15. //          tel. (472) 546 396
  16.  
  17. str thisBBStype[]="OPUS"     // Works only for OPUS.
  18.    ,command  [10]            // Current prompt (value)
  19.    ,line     [80]            // Line for string storage.
  20.  
  21.                              // For the Global storage:
  22.    ,global   []="GLOBAL"     // Global script.
  23.    ,bbstype  []="BTYPE"      // BBS type.
  24.    ,user     []="NAME"       // User name
  25.    ,addr     []="ADDR"       // Address
  26.    ,mail     []="MAIL"       // Mail address
  27.    ,state    []="STATE"      // State
  28.    ,htel     []="HTEL"       // Home phone
  29.    ,wtel     []="WTEL"       // Work phone
  30.    ,passw    []="PASSW"      // Actual password
  31.    ,PutLine  []="PUTLINE"    // Send one line.
  32.    ,cpu      []="CPU"        // Computer model
  33.    ,modem    []="MODEM"      // Type of modem
  34.    ;     
  35.  
  36. int tol = 300                // No activity for ½ minute
  37.    ,stat, tmark              // makes script time out.
  38.    ,Enter = 13               // Code for Enter (CR).
  39.    ;
  40.  
  41. //-----------------------------------------------------------
  42. // Script starts here.
  43. //-----------------------------------------------------------
  44.  
  45. main()
  46. {
  47. int c, i
  48.    ,na                  // Trig for user name,
  49.    ,sa                  // street address
  50.    ,pc                  // postal code
  51.    ,hp                  // Home phone
  52.    ,uo                  // Use other systems?
  53.    ,wo                  // Which ones?
  54.    ,sl                  // Interests?
  55.    ;
  56.  
  57.   entry();                               // Updates colors & status bar. 
  58.  
  59. // Only if online.
  60.  
  61.   if (!carrier()) 
  62.   { alarm(1);
  63.     status_wind ("T²: THIS SCRIPT ONLY WORKS IF YOU'RE ONLINE!",20);
  64.     return (0);
  65.   }
  66.  
  67.   call (global,"R",bbstype,line);        // Get BBS type. Should be OPUS.
  68.  
  69.   if (line != thisBBStype)
  70.   { wrongBBS();
  71.     return (-1);
  72.   }
  73.  
  74. // Check incoming text.
  75.  
  76.   waitfor ("register? (y,n)",5);
  77.   call (PutLine,"Y",Enter);
  78.  
  79.   na = track ("FIRST and LAST):", 0);    // User name.
  80.   sa = track ("Address:", 0);            // ......street address
  81.   pc = track ("PostCode", 0);            // Postal code & place
  82.   hp = track (" Number:", 0);            // Phone number
  83.   uo = track ("System)?", 0);            // Use other systems?
  84.   wo = track (" one(s):", 0);            // Which ones?
  85.   sl = track ("6 Left> ", 0);            // Interests?
  86.   
  87.   tmark = timer_start (tol);             // wait up to 30 sec. for 
  88.                                          // each response.
  89.   while ((stat=trig()) > 0)              // answer any logon questions
  90.   { if (stat == na)                      // User name
  91.       output (user);
  92.  
  93.     else if (stat == sa)                 // Street address
  94.       output (addr);
  95.  
  96.     else if (stat == pc)                 // Postal code.
  97.       output (mail);                     // give street address.
  98.  
  99.     else if (stat == hp)                 // Home telephone number
  100.       output (htel);                     // give home phone number.
  101.  
  102.     else if (stat == uo)                 // Use other systems?
  103.       call (PutLine,"Y",Enter);
  104.  
  105.     else if (stat == wo)                 // Which ones?
  106.       call (PutLine,"Irrelevant",Enter);
  107.  
  108.     else if (stat == sl)                 // Special interests?
  109.       break;
  110.   }
  111.   release();
  112.  
  113.   na = track ("Left>", 0);               // Answer nothing to this.
  114.   sl = track ("Last Line>", 0);          // Last line.
  115.   sa = track ("e running?", 0);          // What equipment?
  116.   
  117.   call (PutLine,"BBSing", Enter);
  118.   tmark = timer_start (tol);             // wait up to 30 sec. for 
  119.                                          // each response.
  120.   while ((stat=trig()) > 0)              // answer any logon questions
  121.   { if (stat==na || stat==sl)            // No answer
  122.       call (PutLine," ", Enter);
  123.  
  124.     else if (stat == sa)                 // Equipment?
  125.       break;
  126.   }
  127.   release();
  128.  
  129.   read (cpu,line);                       // Get computer equipment.
  130.   call (PutLine,line, Enter);
  131.   read (modem,line);                     // Get modem.
  132.   call (PutLine,line, Enter);
  133.   waitfor ("Line",1);
  134.   call (PutLine," ", Enter);
  135.  
  136.   waitfor ("this system:",2);
  137.   read (passw,line);                     // Get password.
  138.   cputs (line);
  139.   cputc (Enter);
  140.   waitfor ("e more time:",2);            // One more time.
  141.   cputs (line);
  142.   cputc (Enter);
  143.  
  144.   waitfor ("CITY and STATE:", 2);
  145.   
  146.   read (mail,line);                      // Get city.
  147.   for (i=0; i<strlen (line); ++i)
  148.   { c=subchr (line,i);                   // Don't send number or space.
  149.     if (c >='A') cputc (c);
  150.   }
  151.   cputc (' ');
  152.   output (state);                        // Send country.
  153.  
  154.   waitfor ("[y,N,?=help]?", 3);
  155.   call (PutLine,"n",Enter);
  156.   waitfor (" [1,2]",1);
  157.   call (PutLine,"1",Enter);
  158.   waitfor ("[y,N,?=help]?", 3);
  159.   call (PutLine,"Y",Enter);
  160.   waitfor ("[y,N,?=help]?", 3);
  161.  
  162.   na = track ("ENTER to continue",1);
  163.   sl = track ("Select:", 0);
  164.   wo = track ("More [Y,n,=]?", 0);       // Stop list.
  165.  
  166.   call (PutLine,"Y",Enter);
  167.  
  168.   tmark = timer_start (tol);             // wait up to 30 sec.
  169.  
  170.   cputs ("^M");
  171.  
  172.   while ((stat=trig()) > 0)              // answer any logon questions
  173.   { if (stat == na)                      // No answer
  174.       cputs ("^M");
  175.  
  176.     else if (stat == wo)                 // More?
  177.       call (PutLine, "N", Enter);        // No.
  178.   
  179.     else if (stat == sl)                 // Select?
  180.       break;
  181.   }
  182.   release();
  183.  
  184.   return (0);
  185. }
  186.                                          
  187. //-----------------------------------------------------------
  188. // Wrong BBS type.
  189. //-----------------------------------------------------------
  190.  
  191. wrongBBS()
  192. {
  193. str help[48];
  194.  
  195.     failtone();                          // Alarm.    
  196.     help = "This script is for ";        // Catenate strings.
  197.     strcat (help,thisBBStype);
  198.     strcat (help," only!");
  199.     status_wind (help,20);               // Display message for 2 sec.
  200. }
  201.  
  202. //-----------------------------------------------------------
  203. // Play fail tone.
  204. //-----------------------------------------------------------
  205.  
  206. failtone()
  207. {
  208.   int n;
  209.   for (n=140; n > 10; n = 100*n/120) 
  210.   { tone(n*10,12);                       // Fail tone!!
  211.     terminal();                          // Process text.
  212.   }
  213. }
  214.  
  215. //-----------------------------------------------------------
  216. // Routine to update colors and status bar.
  217. //-----------------------------------------------------------
  218.  
  219. entry ()
  220. {
  221.   _back_color = 1;
  222.   _fore_color = 14;
  223.   update_term();
  224. }
  225.  
  226. //-----------------------------------------------------------
  227. // Free timer and tracks.
  228. //-----------------------------------------------------------
  229.  
  230. release()
  231. {
  232.   timer_free (tmark);
  233.   track_free(0);
  234. }
  235.  
  236. //-----------------------------------------------------------
  237. //  Trig loop. Waits here until either one "trig string" is
  238. //  found, or we have a time-out, or carrier is lost.
  239. //-----------------------------------------------------------
  240.  
  241. trig()
  242. {
  243. int i;
  244.   do
  245.   { terminal();
  246.   }  while (!time_up (tmark)             // Loop until time-out
  247.           && carrier()                   // or carrier lost
  248.           && (i=track_hit(0))==0);       // or we trigged.
  249.   if (i==0) 
  250.     i = -1;                              // Error!
  251.   else
  252.     timer_restart (tmark,tol);           // Restore timer.
  253.   return (i);
  254. }
  255.  
  256. //-----------------------------------------------------------
  257. // Send a global variable to the BBS.
  258. //-----------------------------------------------------------
  259.  
  260. output (str name)
  261. {
  262. int i;
  263.  
  264.   call (global,"R",name,l